//
//  XHomeItemCell.m
//  Bees
//
//  Created by Xiaohan on 2018/12/18.
//  Copyright © 2018 xiaohan. All rights reserved.
//

#import "XHomeItemCell.h"
#import "FoundModel.h"
@implementation XHomeItemCell

- (void)setModel:(FoundRecommendModel *)model{
    _model = model;
    [self.imageV sd_setImageWithURL:String_To_URL(model.logo) placeholderImage:nil];
    self.titleLab.text = model.name;
    self.subLab.text = model.introduction;
}

- (void)setupUI{
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor =  UIColor.clearColor;
//    UIView *backV = [UIView new];
//    backV.backgroundColor = UIColor.whiteColor;
//    backV.layer.cornerRadius = AdaptedWidth(13.0f);
//    [backV setLayerShadow:kShadowColor offset:CGSizeMake(0, 0) radius:6];
//    [self.contentView addSubview:backV];
//    [backV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(kNormalSpace*.5);
//        make.left.mas_equalTo(kNormalSpace);
//        make.bottom.mas_equalTo(-kNormalSpace*.5);
//        make.width.equalTo(backV.mas_height).multipliedBy(1.0f);
//    }];
    [self.contentView addSubview:self.imageV];
    [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(kNormalSpace*.5);
        make.left.mas_equalTo(kNormalSpace);
        make.bottom.mas_equalTo(-kNormalSpace*.5);
        make.width.equalTo(self.imageV.mas_height).multipliedBy(1.0f);
    }];
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageV.mas_right).offset(AdaptedWidth(11.0f));
        make.top.equalTo(self.imageV.mas_top).offset(AdaptedWidth(10.0f));
    }];
    [self.contentView addSubview:self.subLab];
    [self.subLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageV.mas_right).offset(AdaptedWidth(11.0f));
        make.right.mas_equalTo(AdaptedWidth(-11.0f));
        make.bottom.equalTo(self.imageV.mas_bottom).offset(AdaptedWidth(-10.0f));
    }];
    [self.contentView addSubview:self.collectionIcon];
    [self.collectionIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(AdaptedWidth(-24));
    }];
    
}

- (UIImageView*)imageV{
    if (!_imageV) {
        _imageV = [UIImageView new];
        _imageV.contentMode = UIViewContentModeScaleAspectFit;
        ViewRadius(_imageV, AdaptedWidth(13.0f));
    }
    return _imageV;
}

- (UILabel*)titleLab{
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.font =  kBoldFont(16);
        _titleLab.numberOfLines = 1;
    }
    return _titleLab;
}
- (UILabel*)subLab{
    if (!_subLab) {
        _subLab = [UILabel new];
        _subLab.font = kDefaultFont(12);
        _subLab.numberOfLines = 1;
        _subLab.textColor = kColorTextGray;
    }
    return _subLab;
}
- (UIImageView*)collectionIcon{
    if (!_collectionIcon) {
        _collectionIcon = [UIImageView new];
        _collectionIcon.image = IMAGE_NAMED(@"collectionIcon");
        _collectionIcon.contentMode = UIViewContentModeScaleAspectFit;
        _collectionIcon.hidden = YES;
    }
    return _collectionIcon;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
